package com.deer.wms.busine.tactic.web;

import com.deer.wms.busine.tactic.model.Batch.BatchTacticDetailDetail;
import com.deer.wms.busine.tactic.model.Batch.BatchTacticDetailDetailCriteria;
import com.deer.wms.busine.tactic.service.BatchTacticDetailDetailService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.deer.wms.project.root.core.result.Result;
import com.deer.wms.project.root.core.result.ResultGenerator;

import java.util.List;

/**
* Created by guo on 2019/11/29.
*/
@Api(description = "批次格式选择信息api接口")
@RestController
@RequestMapping("/batch/tactic/detail/details")
public class BatchTacticDetailDetailController {

    @Autowired
    private BatchTacticDetailDetailService batchTacticDetailDetailService;

    @PostMapping("/insert")
    public Result add(@RequestBody BatchTacticDetailDetail batchTacticDetailDetail) {
        batchTacticDetailDetailService.save(batchTacticDetailDetail);
        return ResultGenerator.genSuccessResult();
    }

    @GetMapping("/delete")
    public Result delete(Integer id) {
        batchTacticDetailDetailService.removeById(id);
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("/update")
    public Result update(@RequestBody BatchTacticDetailDetail batchTacticDetailDetail) {
        batchTacticDetailDetailService.updateById(batchTacticDetailDetail);
        return ResultGenerator.genSuccessResult();
    }

    @GetMapping("/detail")
    public Result detail(Integer id) {
        BatchTacticDetailDetail batchTacticDetailDetail = batchTacticDetailDetailService.getById(id);
        return ResultGenerator.genSuccessResult(batchTacticDetailDetail);
    }

    @GetMapping("/list")
    public Result list(BatchTacticDetailDetailCriteria criteria) {
        PageHelper.startPage(criteria.getPageNum(), criteria.getPageSize());
        List<BatchTacticDetailDetail> list = batchTacticDetailDetailService.list();
        PageInfo pageInfo = new PageInfo(list);
        return ResultGenerator.genSuccessResult(pageInfo);
    }

}
